package com.pacifico.telebusca.web.util;

import java.sql.Timestamp;
import java.util.Calendar;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;

public final class Util {

	public static Timestamp getDate() {
		return new Timestamp(Calendar.getInstance().getTimeInMillis());
	}

	public static String obtenerNombreUsuario(SecurityContext securityContex)
			throws Exception {

		if (securityContex == null) {
			throw new Exception(" Su session a expirado ");
		}
		Authentication authentication = securityContex.getAuthentication();

		if (authentication == null) {
			throw new Exception(" Fallo ");
		}
		String name = authentication.getName();
		return name;
	}
	
	
}
